<%@ page import="com.ljx.demo6.utils.DataBaseUtil" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="com.ljx.demo6.dao.NewsDao" %>
<%@ page import="com.ljx.demo6.domain.NewsInfo" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>JSP - Hello World</title>
    <style>
        .header{
            height: 55px;
            line-height: 55px;
            width: 100%;
            box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .05);
        }
        .header-main{
            width: 1200px;
            margin: 0 auto;
            display: flex;
            align-items: center;
        }
        .header div{
            padding: 0 10px;
            cursor: pointer;
        }
        .news{
            width: 800px;
            margin: 0 auto;
            margin-top: 10px;
        }
    </style>
</head>
<body>
<div class="header">
   <div class="header-main">
       <div style="color: #409eff;">首页</div>
       <div><a href="admin.jsp" style="text-decoration: none; color: black">管理</a></div>
   </div>
</div>
<div class="news">
    <%
        List<NewsInfo> newsAll = NewsDao.getNewsAll();
        int idx = 1;
        for (NewsInfo newsInfo : newsAll) {
    %>
    <table style="width: 100%; border-collapse: collapse; margin-top: 10px">
        <thead style="background-color: #f2f2f2;">
        <tr>
            <th colspan="2" style="padding: 10px; text-align: center; border-bottom: 2px solid #ccc;">
                第<%=idx++%>个新闻
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td style="width: 20%; padding: 10px; text-align: right; border-bottom: 1px solid #ccc;">标题：</td>
            <td style="padding: 10px; border-bottom: 1px solid #ccc;"><%=newsInfo.getTitle()%>
            </td>
        </tr>
        <tr>
            <td style="padding: 10px; text-align: right; border-bottom: 1px solid #ccc;">类型：</td>
            <td style="padding: 10px; border-bottom: 1px solid #ccc;"><%=newsInfo.getType()%>
            </td>
        </tr>
        <tr>
            <td style="padding: 10px; text-align: right; border-bottom: 1px solid #ccc;">内容：</td>
            <td style="padding: 10px; border-bottom: 1px solid #ccc;"><%=newsInfo.getContent()%>
            </td>
        </tr>
        <tr>
            <td style="padding: 10px; text-align: right; border-bottom: 1px solid #ccc;">发布时间：</td>
            <td style="padding: 10px; border-bottom: 1px solid #ccc;"><%=newsInfo.getCreateTime()%>
            </td>
        </tr>
        <tr>
            <td style="padding: 10px; text-align: right; border-bottom: 1px solid #ccc;">更新时间：</td>
            <td style="padding: 10px; border-bottom: 1px solid #ccc;"><%=newsInfo.getUpdateTime()%>
            </td>
        </tr>
        <%--    <tr>--%>
        <%--        <td colspan="2">--%>
        <%--            <form method="POST" action="delete.jsp" style="text-align: right">--%>
        <%--                <input name="id" value="<%=resultSet.getLong("id")%>" type="text" style="display: none;">--%>
        <%--                <button type="submit" class="delete-button">删除</button>--%>
        <%--            </form>--%>
        <%--        </td>--%>
        <%--    </tr>--%>
        </tbody>
    </table>
    <%
        }
    %>
</div>
</body>
</html>